﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_AttorneyLogo : System.Web.UI.Page
{
    int projectid;
    int AttorneyLogoId;
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            projectid = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["projectid"]));
            AttorneyLogoId = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["Id"]));
            string _strPassWord = SysFun.IsSQL(SysFun.ToTrim(Request.QueryString["PassWord"]));
            if (!HZ.MBSM.BLL.Login.CheckPerson("system", _strPassWord,"0"))
            {
                Response.Write("<script>window.alert('对不起,密码不对！');</script>");
                Response.Write("<script>window.location=\"systemlogo.aspx?Projectid=" + projectid.ToString() + "&Id=" + AttorneyLogoId.ToString() + "\"</script>");
            }

        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
       
        if (TextBox1.Text == "")
        {
            Response.Write("<script>window.alert('请填写密码')</script>");
        }
        else
        {
            string _strPassWord = TextBox1.Text.ToString().Trim();
            
            int count = 0;
            Db db = new Db();
            System.Data.IDataReader dr;
            sql = "select account.AccountName from account,project where  projectid=" + projectid.ToString() + " and account.accountid=project.accountid and  pwd_bid='" + _strPassWord + "'";
            dr = db.DataReader(sql);
            while (dr.Read())
            {
                count = 1;
            }
            db.Close();
            dr.Close();
            dr.Dispose();
            if (count > 0)
            {
                _strPassWord = SysFun.PasswordEncrypt(_strPassWord);
                Response.Write("<script>window.alert('解密成功');</script>");
                Button1.Dispose();
                Response.Write("<script>window.location=\"superviseLogo.aspx?projectid=" + projectid.ToString() + "&Id=" + AttorneyLogoId.ToString() + "&PassWord=" + _strPassWord + "\"</script>");
            }
            else
            {
                Response.Write("<script>window.alert('密码错误！请重新输入');</script>");
                TextBox1.Text = "";

            }
           
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
    }
}
